package son.nt.adapter;

import java.util.ArrayList;

import son.nt.R;
import son.nt.entities.ItemDemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ItemAreaAdapter extends BaseAdapter{
	private Context mContext = null;
	private ArrayList<ItemDemo> list = null;
	public ItemAreaAdapter(Context mContext, ArrayList<ItemDemo> list){
		this.mContext = mContext;
		this.list = list;
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public ItemDemo getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if(convertView == null){
			LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.row_item_demo, null);
		}else{
			view = convertView;
		}
		
		ItemDemo item = list.get(position);
		TextView txtItemName = (TextView) view.findViewById(R.id.txtItemName);
		TextView txtItemCommand = (TextView) view.findViewById(R.id.txtItemCommand);
		TextView txtItemTime = (TextView) view.findViewById(R.id.txtItemTime);
		
		txtItemName.setText(item.getName());
		txtItemCommand.setText(item.getCommand());
		txtItemTime.setText(item.getTime());
		return view;
	}
	
}
